var loadPage = function(page, id){

	if(document.getElementById(id)){

		$("#"+ id).html( '<img src="http://cricworld.shastrasoftech.com/images/ajax-loader.gif" />' );
		$("#"+ id).load(page);
		
	}	
	
}

//function to check duplicate of league
var checkLeague = function(name)
{
	
	var dataString = "name="+name;
			$.ajax({		
			   type: "Get",
			   url: leagueUrl,
			   data: dataString,
			    success: function(html)
			    {
					
					document.getElementById('divLeagueName').innerHTML = "<span class='error'>"+html+"</span>";
					
					
			    }
		});
};

//function to check duplicate of loggedin emai Id while sending invitations
var checkEmail = function(name)
{
	
	var dataString = "name="+name;
			$.ajax({		
			   type: "Get",
			   url: emailUrl,
			   data: dataString,
			    success: function(html)
			    {
					
					document.getElementById('divEmail').innerHTML = "<span class='error'>"+html+"</span>";
					
					
			    }
		});
};
//function to check duplicate of loggedin emai Id while sending challenges
var checkChallengeEmail = function(name)
{
	
	var dataString = "name="+name;
			$.ajax({		
			   type: "Get",
			   url: challengeEmailUrl,
			   data: dataString,
			    success: function(html)
			    {
					
					document.getElementById('divEmail').innerHTML = "<span class='error'>"+html+"</span>";
					
					
			    }
		});
};

function validateForgotPwd()
{
	var emailaddress = document.getElementById('emailaddress').value;
	var counter=0;
		
		if(emailaddress=="")
		{
			document.getElementById('errorMsg').innerHTML = "<font color='red'>Please enter email address</font>";
			counter = counter +1;
		}
		if(counter > 0)
		{
			return false;
		}
		else
		{
			document.getElementById('errorMsg').html = "";
			return true;
		}
}
function acceptRequest(status,cid)
{
		
		var dataString = "status="+status+"&cid="+cid;
		
		$.ajax({		
		   type: "Get",
		   url: acceptUrl,
		   data: dataString,
		    success: function(html)
		    {
			
				if(html == '0')
				{
					
					document.getElementById('divAccept').innerHTML = "<span class='error'>You have to select team.</span>";
				}
				else
				{
					window.location = document.URL;
				}
				
		    }
	});
	
	
};
function validateEmail()
{
	var emailaddress = document.getElementById('invite').value;
	var counter=0;
		
		if(emailaddress=="")
		{
			document.getElementById('divEmail').innerHTML = "<font color='red'>Please enter email address</font>";
			counter = counter +1;
		}
		if(counter > 0)
		{
			return false;
		}
		else
		{
			document.getElementById('divEmail').html = "";
			return true;
		}
}
function sendGcredentials()
{
	var emailaddress = document.getElementById('email_add').value;
	var pwd			 = document.getElementById('pwd').value;
	
	var dataString = "emailaddress="+emailaddress+"&pwd="+pwd;
	
	$.ajax({		
	   type: "Get",
	   url: gmailUrl,
	   data: dataString,
	    success: function(html)
	    {
		
		document.getElementById('showContacts').innerHTML = html;
			
	    }
});
}
//function to set status on check of checkbox
function checkStatus(status)
{
	
		var i = $("select option[id="+ status +"]").attr('selected');
		
		if(i == true){			
			$("select option[id="+ status +"]").attr('selected','');
		} else {
			$("select option[id="+ status +"]").attr('selected','selected');
		}
		
}


